<!DOCTYPE html>
<html class="no-js">
  <head>
    <meta charset="utf-8">
    <title><%= render_alchemy_title %></title>
    <link rel="shortcut icon" href="<%= asset_path('alchemy/favicon.ico') %>">
    <%= csrf_meta_tag %>
    <meta name="robots" content="noindex">
    <%= stylesheet_link_tag('alchemy/admin/all', media: 'screen', 'data-turbolinks-track' => true) %>
    <%= stylesheet_link_tag('alchemy/print', media: 'print', 'data-turbolinks-track' => true) %>
    <%= yield :stylesheets %>
    <script>
      // Global Alchemy JavaScript object.
      var Alchemy = {};
      // Setting TinyMCE path.
      var tinyMCEPreInit = {
        <% if ActionController::Base.config.asset_host_set? %>
        base: '<%= asset_url(assets_prefix + '/tinymce') %>',
        <% else %>
        base: '<%= asset_path(assets_prefix + '/tinymce') %>',
        <% end %>
        suffix: '.min'
      };
      // Store regular expression for external link url matching.
      Alchemy.link_url_regexp = <%= link_url_regexp.inspect %>;
      // Holds the default Alchemy TinyMCE configuration
      Alchemy.Tinymce = {
        defaults: {
          plugins: '<%= Alchemy::Tinymce.plugins.join(',') %>',
          <% Alchemy::Tinymce.init.each do |k, v| %>
          <%= k %>: <%== v.to_json %>,
          <% end %>
        }
      };
    </script>
    <%= render 'alchemy/admin/partials/routes' %>
    <%= javascript_include_tag('alchemy/admin/all', 'data-turbolinks-track' => true) %>
    <%= yield :javascript_includes %>
  </head>
  <%= content_tag :body, id: 'alchemy', class: alchemy_body_class do %>
    <noscript>
      <h1><%= Alchemy.t(:javascript_disabled_headline) %></h1>
      <p><%= Alchemy.t(:javascript_disabled_text) %></p>
    </noscript>
    <div id="overlay">
      <div id="overlay_text_box">
        <span id="overlay_text"><%= Alchemy.t(:please_wait) %></span>
      </div>
    </div>
    <div id="left_menu">
      <div id="main_navi">
        <% sorted_alchemy_modules.each do |alchemy_module| %>
          <%= alchemy_main_navigation_entry(alchemy_module) %>
        <% end %>
        <%= yield(:alchemy_main_navigation) %>
      </div>
      <div id="logout">
        <% if current_alchemy_user %>
          <%= link_to_dialog(
            "#{render_icon('exit module')}<label>#{Alchemy.t(:leave)}</label>".html_safe,
            alchemy.leave_admin_path, {
              size: "300x155",
              title: Alchemy.t("Leave Alchemy")
          }, {'data-alchemy-hotkey' => 'alt+q'}) %>
        <% else %>
          <%= link_to(alchemy.root_path) do %>
            <span class="module icon exit"></span>
            <label><%= Alchemy.t(:leave) %></label>
          <% end %>
        <% end %>
      </div>
    </div>
    <% if current_alchemy_user %>
    <div id="top_menu">
      <div id="header">
        <% if @locked_pages.present? %>
          <div id="locked_pages">
            <%= render partial: 'alchemy/admin/pages/locked_page', collection: @locked_pages %>
          </div>
        <% end %>
        <div id="user_info">
          <%= current_alchemy_user_name %>
          <%= select_tag 'change_locale',
            options_for_select(translations_for_select, ::I18n.locale),
            class: 'alchemy_selectbox tiny' %>
        </div>
      </div>
      <div id="toolbar">
        <%= yield(:toolbar) %>
      </div>
    </div>
    <% end %>
    <%= render :partial => 'alchemy/admin/partials/flash_notices' %>
    <div id="main_content">
      <%= yield %>
    </div>
    <script>
      // Store current locale for javascript translations.
      Alchemy.locale = '<%= ::I18n.locale %>';
      // Setting the correct locale for select2 dropdown replacement.
      $.extend($.fn.select2.defaults, $.fn.select2.locales['<%= ::I18n.locale %>']);
    </script>
    <%= render 'alchemy/admin/uploader/setup' %>
    <%= yield(:javascripts) %>
  <% end %>
</html>
